﻿@model Webchat.Models.Chatroom

<script src="@Url.Content("~/Scripts/jquery-1.5.1.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>

@using (Html.BeginForm()) {
    @Html.ValidationSummary(true)
    <fieldset>
        <legend>Chatroom</legend>

        <div class="editor-label">
            @Html.LabelFor(model => model.Name)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Name)
            @Html.ValidationMessageFor(model => model.Name)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.MaximumUsers)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.MaximumUsers)
            @Html.ValidationMessageFor(model => model.MaximumUsers)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.IsPublic)
        </div>
        <div class="editor-field">
            @Html.RadioButton("IsPublic", "Yes") Yes 
            @Html.RadioButton("IsPublic", "No")  No
            @Html.ValidationMessageFor(model => model.IsPublic)
        </div>
        <script type="text/javascript">
            $("input[name='IsPublic']").change(function () {
                $("#PermittedUsers").toggle(this.value == "No");
            });
        </script>
        <div id="PermittedUsers">
        <p>Hei</p>
        @Html.ListBoxFor(model => model.aspnet_User.UserName, ViewData["users"] as SelectList) 
        </div>
        <p>
            <input type="submit" value="Create" />
        </p>
    </fieldset>
}

<div>
    @Html.ActionLink("Back to List", "Index")
</div>
